//
//  KKNetworkRequest+V1.m
//  ReplyAssistant
//
//  Created by liaozhenming on 2018/11/23.
//  Copyright © 2018 KK. All rights reserved.
//

#import "KKNetworkRequest+V1.h"

@implementation KKNetworkRequest (V1)

//  微信登录
+ (instancetype)request_wxloginWithCode:(NSString*)code {
    
    NSString *interfaceName = [NSString stringWithFormat: @"/cb/%@",code];
    return [KKNetworkRequest requestWithHost: APP_Request_BasicURLString interfaceName:interfaceName parmeters: nil methodType:KKNetworkRequestMethodType_Get];
}

//  客服注册并且登录
+ (instancetype)request_loginWithTicketId:(NSString*)ticketid deviceId:(NSString*)deviceId uid:(NSString*)uid{
    
    NSMutableDictionary *parameter = [NSMutableDictionary dictionary];
    [parameter setValue: uid forKey: @"uid"];
    [parameter setValue: deviceId forKey: @"devid"];
    [parameter setValue: ticketid forKey: @"ticket"];
    
    NSString *interfaceName = [NSString stringWithFormat: @"/merchant"];
    return [KKNetworkRequest requestWithHost: APP_Request_BasicURLString interfaceName:interfaceName parmeters: parameter methodType:KKNetworkRequestMethodType_Put];
}

+ (instancetype)request_loginWithTicketId:(NSString*)ticketid deviceId:(NSString*)deviceId nickName:(NSString*)nickname headimg:(NSString*)headimg {
    NSMutableDictionary *parameter = [NSMutableDictionary dictionary];
    [parameter setValue: headimg forKey: @"headimg"];
    [parameter setValue: nickname forKey: @"nick"];
    [parameter setValue: deviceId forKey: @"devid"];
    [parameter setValue: ticketid forKey: @"ticket"];
    
    NSString *interfaceName = [NSString stringWithFormat: @"/merchant"];
    return [KKNetworkRequest requestWithHost: APP_Request_BasicURLString interfaceName:interfaceName parmeters: parameter methodType:KKNetworkRequestMethodType_Put];
}

//  获取会话列表
+ (instancetype)request_getChatItems {
    return [KKNetworkRequest requestWithHost: APP_Request_BasicURLString interfaceName: @"/thread" parmeters: nil methodType:KKNetworkRequestMethodType_Get];
}

//  获取单个会话
+ (instancetype)request_getChatItemDetail:(NSString*)itemId {
    NSString *interfaceName = [NSString stringWithFormat: @"/thread/%@",itemId];
    return [KKNetworkRequest requestWithHost: APP_Request_BasicURLString interfaceName:interfaceName parmeters: nil methodType:KKNetworkRequestMethodType_Get];
}

//  回复消息
+ (instancetype)request_replyContent:(NSString*)content receiveId:(NSString*)receiveId {
    
    NSMutableDictionary *parameter = [NSMutableDictionary dictionary];
    [parameter setValue: @"text" forKey: @"type"];
    [parameter setValue: content forKey: @"content"];
    
    NSString *interfaceName = [NSString stringWithFormat: @"/thread/%@",receiveId];
    return [KKNetworkRequest requestWithHost: APP_Request_BasicURLString interfaceName:interfaceName parmeters: parameter methodType:KKNetworkRequestMethodType_Post];
}

+ (instancetype)request_replyContentWithParmeters:(NSDictionary*)parmeters receiveId:(NSString*)receiveId {
    
    NSString *interfaceName = [NSString stringWithFormat: @"/thread/%@",receiveId];
    return [KKNetworkRequest requestWithHost: APP_Request_BasicURLString interfaceName:interfaceName parmeters: parmeters methodType:KKNetworkRequestMethodType_Post];
}

//  删除会话
+ (instancetype)request_deleteChatItem:(NSString*)itemId {
    NSString *interfaceName = [NSString stringWithFormat: @"/thread/%@",itemId];
    return [KKNetworkRequest requestWithHost: APP_Request_BasicURLString interfaceName:interfaceName parmeters: nil methodType:KKNetworkRequestMethodType_Delete];
}

//  停止开启接入服务
+ (instancetype)request_updateServiceStatus:(BOOL)status {
    NSMutableDictionary *parameter = [NSMutableDictionary dictionary];
    [parameter setValue: @(status) forKey: @"online"];
    
    return [KKNetworkRequest requestWithHost: APP_Request_BasicURLString interfaceName:@"/status" parmeters: parameter methodType:KKNetworkRequestMethodType_Post];
}

//  获取客服信息
+ (instancetype)request_getUserInfo {
    return [KKNetworkRequest requestWithHost: APP_Request_BasicURLString interfaceName:@"/status" parmeters: nil methodType:KKNetworkRequestMethodType_Get];
}

//  更换客服头像信息
+ (instancetype)request_updateUserHeadimg:(NSString*)imagePath {
    NSMutableDictionary *parameter = [NSMutableDictionary dictionary];
    [parameter setValue: imagePath forKey: @"url"];
    
    return [KKNetworkRequest requestWithHost: APP_Request_BasicURLString interfaceName:@"/status/headimg" parmeters: parameter methodType:KKNetworkRequestMethodType_Post];
}

//
+ (instancetype)request_ping {
    return [KKNetworkRequest requestWithHost: APP_Request_BasicURLString interfaceName:@"/ping" parmeters: nil methodType:KKNetworkRequestMethodType_Get];
}

@end
